package com.hgkj.cloud.base.scheme.table;

import com.hgkj.cloud.base.scheme.ClsAnswerRequest;
import com.hgkj.cloud.base.scheme.ClsAnswerResult;
import com.hgkj.cloud.base.scheme.ClsScore;

import java.math.BigDecimal;
import java.util.Map;

/**
 * 四、卡特尔16种个性测验（16Pf）共187题，由于Java无法使用16Pf来定义，所以改成Pf16
 */
public class Table4 extends AbstractTable implements TableCalculate{
    String code = "Pf16";

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public ClsAnswerResult calc(ClsAnswerRequest answer) {
        return GetPf16FactorScore(answer);
    }

    @Override
    public String[] report(Map map) {
        return GetPf16Report(map);
    }

    //
    private ClsAnswerResult GetPf16FactorScore(ClsAnswerRequest answer) {
        ClsAnswerResult result = new ClsAnswerResult();
        result.setMessage("");
        result.setType(answer.getType());
        result.setUuid(answer.getUuid());
        try {
            // 1正确题数
            int MAX_NUM = 187;

            int intI;
            String[] strAnswer_c = answer.getAnswer().split(g_sChar);
            if (strAnswer_c.length > 1) {
                for (intI = 1; intI < strAnswer_c.length; intI++) {
                    strAnswer_c[intI] = strAnswer_c[intI].trim();
                }
            }

            String[] sAnswer = strAnswer_c[0].toString().split(g_nChar);

            if (sAnswer.length != MAX_NUM) {
                result.setMessage("答案数量不符！");
                return result;
            }

            // 总计分
            int[] arrTotalA = new int[187];
            // 内容为题目编号
            // 第一组0,1,2；第二组2,1,0；第三组0,1,0；第四组0,0,1；第五组1,0,0
            int[][] intScoreA = { { 0, 1, 2 }, { 2, 1, 0 }, { 0, 1, 0 }, { 0, 0, 1 }, { 1, 0, 0 } };
            String[] strNumberA = { "26,27,51,76,151,5,29,79,80,154,6,31,32,57,81,106,8,82,83,107,108,157,158,"
                    + "9,34,84,159,35,60,61,85,86,135,161,11,12,62,87,137,162,63,64,89,139,14,15,90,116,141,165,166,"
                    + "16,41,66,67,92,19,44,68,93,94,144,45,95,120,170,22,96,97,121,122,23,24,123,172,75,100,125,175",
                    "3,52,101,126,176,4,30,55,104,105,129,130,179,7,56,131,155,156,180,181,33,58,132,133,182,183,"
                            + "59,109,134,160,184,185,10,36,110,111,136,186,37,112,138,163,13,38,88,113,114,164,"
                            + "39,40,65,91,115,140,17,42,117,142,167,18,43,69,118,119,143,168,20,21,46,70,145,169,"
                            + "47,71,72,146,171,48,73,98,147,148,173,25,49,50,74,99,124,149,150,174",
                    "28,53,54,78,103,128,152", "77,102,127,153", "177,178" };

            String[] strSubA;

            // 因子计分
            String[] strGeneNumA = { "3,52,101,126,176,26,27,51,76,151",
                    "28,53,54,78,103,128,152,77,102,127,153,177,178", "4,30,55,104,105,129,130,179,5,29,79,80,154",
                    "7,56,131,155,156,180,181,6,31,32,57,81,106", "33,58,132,133,182,183,8,82,83,107,108,157,158",
                    "59,109,134,160,184,185,9,34,84,159", "10,36,110,111,136,186,35,60,61,85,86,135,161",
                    "37,112,138,163,11,12,62,87,137,162", "13,38,88,113,114,164,63,64,89,139",
                    "39,40,65,91,115,140,14,15,90,116,141,165,166", "17,42,117,142,167,16,41,66,67,92",
                    "18,43,69,118,119,143,168,19,44,68,93,94,144", "20,21,46,70,145,169,45,95,120,170",
                    "47,71,72,146,171,22,96,97,121,122", "48,73,98,147,148,173,23,24,123,172",
                    "25,49,50,74,99,124,149,150,174,75,100,125,175" };

            // 标准分的计分方法
            int[][] intStandValueA;
            String[] vDoctorIdeaA = new String[24]; // 按标准分得到“指导意见”

            float[][] vFactorA = new float[24][2]; // 实际为24个因子
            int i, j;
            for (i = 0; i < vFactorA.length; i++) {
                for (j = 0; j < vFactorA[i].length; j++) {
                    vFactorA[i][j] = 0;
                }
            }

            for (i = 0; i < strNumberA.length; i++) {
                strSubA = strNumberA[i].split(",");
                for (j = 0; j < strSubA.length; j++) {
                    // 所有题目的计分
                    arrTotalA[Integer.parseInt(strSubA[j].trim())
                            - 1] = intScoreA[i][Integer.parseInt(sAnswer[Integer.parseInt(strSubA[j].trim()) - 1]) - 1];
                }
            }

            // 每个因子分别计分（原始分）
            // 前16个
            for (i = 0; i < strGeneNumA.length; i++) {
                strSubA = strGeneNumA[i].split(",");
                for (j = 0; j < strSubA.length; j++) {
                    vFactorA[i][0] += arrTotalA[Integer.parseInt(strSubA[j]) - 1];
                }
            }

            // 因子（标准分），前16个因子有，后8个因子无
            // 按一定的分数得到标准分
            // 2009-02-03 修正，有小数点的是“成人常模”；整数的是“大学生常模”或其他常模
            int vMode = 0;

            switch (vMode) {
                case 0:
                    float[][] subdiv;
                    if (answer.getSex() == 1) // 男
                    {
                        float[][] arrsd = { { 9.63f, 3.17f }, { 7.98f, 2.05f }, { 15.16f, 3.27f }, { 11.18f, 3.56f },
                                { 10.74f, 3.77f }, { 13.25f, 3.23f }, { 9.95f, 3.71f }, { 11.11f, 2.8f }, { 11.12f, 2.39f },
                                { 12.62f, 3.25f }, { 8.71f, 2.56f }, { 11.03f, 3.54f }, { 11.78f, 2.92f }, { 12.75f, 3.3f },
                                { 12.7f, 3.04f }, { 10.83f, 3.69f } };
                        subdiv = arrsd;
                    } else // 女
                    {
                        float[][] arrsd = { { 10.1f, 3.29f }, { 8.69f, 1.94f }, { 14.76f, 3.39f }, { 9.92f, 3.12f },
                                { 10.42f, 3.86f }, { 13.91f, 3.16f }, { 8.85f, 3.53f }, { 11.81f, 2.58f },
                                { 10.82f, 2.68f }, { 12.97f, 3.39f }, { 9.25f, 2.45f }, { 12.35f, 3.42f },
                                { 11.27f, 2.97f }, { 11.98f, 3.15f }, { 13.05f, 2.94f }, { 11.7f, 3.97f } };
                        subdiv = arrsd;
                    }
                    for (i = 0; i < subdiv.length; i++) {
                        // 以下是计算并保留两位小数
                        BigDecimal bd = new BigDecimal(5.5 + 1.5 * (vFactorA[i][0] - subdiv[i][0]) / subdiv[i][1]);
                        vFactorA[i][1] = bd.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue();
                    }

                    break;
                default:
                    float floAge = answer.getAge();
                    if (answer.getSex() == 1) // 男
                    {
                        if (floAge <= 18) // 16-18
                        {
                            int[][] arrValue = { { 2, 3, 5, 7, 9, 10, 12, 14, 16, 20 },
                                    { 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }, { 7, 9, 11, 13, 15, 17, 18, 20, 22, 26 },
                                    { 4, 6, 7, 9, 11, 13, 14, 16, 18, 26 }, { 4, 6, 8, 10, 12, 14, 16, 18, 20, 26 },
                                    { 6, 8, 9, 11, 12, 14, 16, 17, 19, 20 }, { 2, 4, 6, 8, 10, 12, 14, 16, 18, 26 },
                                    { 3, 5, 7, 8, 10, 12, 13, 15, 16, 20 }, { 6, 7, 9, 10, 11, 13, 14, 15, 17, 20 },
                                    { 5, 7, 9, 10, 12, 14, 16, 17, 19, 26 }, { 3, 4, 5, 7, 8, 9, 10, 12, 13, 20 },
                                    { 3, 5, 7, 9, 11, 13, 15, 17, 19, 26 }, { 5, 7, 8, 10, 11, 13, 14, 16, 17, 20 },
                                    { 5, 7, 8, 10, 12, 13, 15, 17, 18, 20 }, { 6, 7, 9, 10, 12, 13, 15, 17, 18, 20 },
                                    { 3, 5, 7, 9, 11, 13, 15, 17, 19, 26 } };
                            intStandValueA = arrValue;

                        } else if (18 < floAge && floAge <= 23) // 19-23
                        {
                            int[][] arrValue = { { 1, 3, 5, 7, 8, 10, 12, 14, 15, 20 },
                                    { 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }, { 7, 9, 11, 12, 14, 16, 17, 19, 21, 26 },
                                    { 4, 6, 7, 9, 11, 13, 14, 16, 18, 26 }, { 4, 6, 8, 10, 12, 14, 16, 18, 20, 26 },
                                    { 6, 7, 9, 11, 12, 14, 15, 17, 18, 20 }, { 2, 4, 6, 8, 10, 12, 14, 16, 18, 26 },
                                    { 4, 6, 7, 9, 10, 11, 13, 14, 16, 20 }, { 6, 7, 9, 10, 11, 13, 14, 15, 17, 20 },
                                    { 5, 7, 9, 10, 12, 14, 15, 17, 19, 26 }, { 3, 4, 6, 7, 8, 10, 11, 12, 14, 20 },
                                    { 3, 5, 7, 8, 10, 12, 14, 16, 17, 26 }, { 6, 7, 9, 10, 11, 13, 14, 16, 17, 20 },
                                    { 6, 8, 9, 11, 12, 14, 16, 17, 19, 20 }, { 6, 7, 9, 10, 12, 13, 15, 16, 18, 20 },
                                    { 3, 5, 7, 9, 11, 13, 15, 16, 18, 26 } };
                            intStandValueA = arrValue;

                        } else {
                            int[][] arrValue = { { 3, 4, 6, 8, 9, 11, 12, 14, 15, 20 },
                                    { 3, 4, 5, 6, 7, 9, 10, 11, 12, 13 }, { 8, 10, 11, 13, 15, 16, 18, 20, 21, 26 },
                                    { 4, 5, 7, 9, 11, 12, 14, 16, 18, 26 }, { 3, 5, 6, 8, 10, 12, 14, 16, 18, 26 },
                                    { 6, 8, 10, 11, 13, 14, 16, 18, 19, 20 }, { 2, 4, 6, 8, 10, 11, 13, 15, 17, 26 },
                                    { 5, 6, 8, 9, 11, 12, 13, 15, 16, 20 }, { 6, 7, 8, 9, 11, 12, 13, 14, 15, 20 },
                                    { 6, 7, 9, 10, 12, 14, 15, 17, 19, 26 }, { 3, 4, 6, 7, 8, 9, 11, 12, 13, 20 },
                                    { 3, 5, 7, 9, 11, 12, 14, 16, 18, 26 }, { 5, 7, 8, 10, 11, 13, 14, 16, 17, 20 },
                                    { 6, 7, 9, 11, 12, 14, 16, 17, 19, 20 }, { 6, 8, 9, 11, 12, 14, 15, 17, 18, 20 },
                                    { 3, 5, 7, 8, 10, 12, 14, 16, 18, 26 } };
                            intStandValueA = arrValue;

                        }
                    } else // 女
                    {
                        if (floAge <= 18) // 16-18
                        {
                            int[][] arrValue = { { 2, 4, 6, 7, 9, 11, 13, 15, 16, 20 },
                                    { 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }, { 7, 9, 11, 12, 14, 16, 18, 19, 21, 26 },
                                    { 3, 5, 7, 8, 10, 12, 14, 15, 17, 26 }, { 5, 7, 9, 10, 12, 14, 16, 18, 20, 26 },
                                    { 6, 8, 9, 11, 13, 14, 16, 17, 19, 20 }, { 2, 4, 6, 8, 10, 12, 14, 15, 17, 26 },
                                    { 5, 6, 8, 9, 11, 12, 13, 15, 16, 20 }, { 6, 7, 8, 10, 11, 12, 14, 15, 17, 20 },
                                    { 7, 9, 10, 12, 13, 15, 16, 18, 20, 26 }, { 3, 4, 6, 7, 8, 9, 11, 12, 13, 20 },
                                    { 3, 5, 7, 9, 11, 13, 15, 16, 18, 26 }, { 6, 8, 9, 10, 12, 13, 14, 16, 17, 20 },
                                    { 5, 6, 8, 10, 12, 13, 15, 17, 18, 20 }, { 6, 8, 9, 11, 12, 14, 15, 17, 18, 20 },
                                    { 3, 5, 6, 8, 10, 12, 14, 16, 18, 26 } };
                            intStandValueA = arrValue;
                        } else if (18 < floAge && floAge <= 23) // 19-23
                        {
                            int[][] arrValue = { { 2, 4, 5, 7, 9, 11, 13, 14, 16, 20 },
                                    { 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }, { 7, 9, 11, 12, 14, 16, 17, 19, 21, 26 },
                                    { 3, 5, 6, 8, 10, 12, 13, 15, 17, 26 }, { 5, 7, 8, 10, 12, 14, 16, 18, 19, 26 },
                                    { 6, 7, 9, 10, 12, 13, 15, 16, 18, 20 }, { 2, 4, 6, 8, 10, 12, 13, 15, 17, 26 },
                                    { 6, 7, 9, 10, 11, 13, 14, 16, 17, 20 }, { 6, 8, 9, 10, 11, 13, 14, 15, 16, 20 },
                                    { 6, 8, 10, 12, 14, 15, 17, 19, 21, 26 }, { 4, 5, 6, 7, 9, 10, 11, 12, 13, 20 },
                                    { 4, 6, 8, 9, 11, 13, 15, 17, 18, 26 }, { 5, 7, 8, 10, 11, 13, 14, 15, 17, 20 },
                                    { 6, 7, 9, 11, 12, 14, 16, 17, 19, 20 }, { 6, 8, 9, 11, 13, 14, 16, 18, 19, 20 },
                                    { 3, 5, 7, 9, 11, 13, 15, 17, 19, 26 } };
                            intStandValueA = arrValue;
                        } else {
                            int[][] arrValue = { { 3, 5, 6, 8, 10, 11, 13, 15, 16, 20 },
                                    { 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }, { 7, 9, 11, 13, 14, 16, 18, 19, 21, 26 },
                                    { 3, 5, 6, 8, 9, 11, 13, 14, 16, 26 }, { 2, 4, 6, 8, 10, 12, 14, 16, 18, 26 },
                                    { 7, 9, 10, 12, 13, 15, 17, 18, 19, 20 }, { 1, 3, 5, 7, 8, 10, 12, 14, 16, 26 },
                                    { 6, 7, 9, 10, 11, 13, 14, 15, 17, 20 }, { 5, 6, 8, 9, 10, 12, 13, 14, 16, 20 },
                                    { 6, 7, 9, 11, 12, 14, 16, 18, 19, 26 }, { 4, 5, 6, 8, 9, 10, 11, 12, 14, 20 },
                                    { 5, 7, 8, 10, 12, 14, 15, 17, 19, 26 }, { 5, 6, 8, 9, 11, 12, 14, 15, 17, 20 },
                                    { 5, 7, 8, 10, 11, 13, 15, 16, 18, 20 }, { 7, 8, 10, 11, 13, 14, 15, 17, 18, 20 },
                                    { 3, 5, 7, 9, 11, 13, 15, 17, 19, 26 } };
                            intStandValueA = arrValue;
                        }
                    }

                    // 真正的标准分（得分）
                    for (i = 0; i < intStandValueA.length; i++) {
                        for (j = 0; j < intStandValueA[1].length; j++) {
                            if (vFactorA[i][0] <= intStandValueA[i][j]) {
                                vFactorA[i][1] = j + 1;
                                break;
                            }
                        }
                    }

                    break;
            }

            BigDecimal bd;
            // 后8个（使用前16个因子的“标准分”）
            // 适应与焦虑型：((38+2* hyx +3* ylx +4* jzx)-(2* wdx +2* gwx +2* zlx)) /
            // 10
            bd = new BigDecimal((38 + 2 * (vFactorA[8][1] - vFactorA[2][1] - vFactorA[6][1] - vFactorA[14][1])
                    + 3 * vFactorA[11][1] + 4 * vFactorA[15][1]) / 10);
            vFactorA[16][0] = bd.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue();

            // 内向与外向型：((2* lqx +3* cqx +4* xfx +5* gwx) - (2* dlx + 11)) / 10
            bd = new BigDecimal((2 * (vFactorA[0][1] - vFactorA[13][1]) + 3 * vFactorA[3][1] + 4 * vFactorA[4][1]
                    + 5 * vFactorA[6][1] - 11) / 10);
            vFactorA[17][0] = bd.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue();

            // 感情用事与安详机警型：((77+2* wdx+2* cqx+2* xfx+2* sgx)-(4* lqx+6* mgx +2*
            // hxx))/10
            bd = new BigDecimal(
                    (77 + 2 * (vFactorA[2][1] + vFactorA[3][1] + vFactorA[4][1] + vFactorA[10][1] - vFactorA[9][1])
                            - 4 * vFactorA[0][1] - 6 * vFactorA[7][1]) / 10);
            vFactorA[18][0] = bd.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue();

            // 怯懦与果断型：((4* cqx +3* hxx +4* syx +4* dlx) - (3* lqx +2* yhx)) / 10
            bd = new BigDecimal((4 * (vFactorA[3][1] + vFactorA[12][1] + vFactorA[13][1])
                    + 3 * (vFactorA[9][1] - vFactorA[0][1]) - 2 * vFactorA[5][1]) / 10);
            vFactorA[19][0] = bd.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue();

            // 心理健康因素：wdx(+xfx + (11 - ylx) + (11 - jzx))
            bd = new BigDecimal(vFactorA[2][1] + vFactorA[4][1] + 11 - vFactorA[11][1] + 11 - vFactorA[15][1]);
            vFactorA[20][0] = bd.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue();

            // 专业有成就者的个性因素：zlx * 2 + yhx * 2 + wdx * 2 + cqx + sgx + syx + dlx
            bd = new BigDecimal((vFactorA[14][1] + vFactorA[5][1] + vFactorA[2][1]) * 2 + vFactorA[3][1]
                    + vFactorA[10][1] + vFactorA[12][1] + vFactorA[13][1]);
            vFactorA[21][0] = bd.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue();

            // 创造力个性因素：(11-lqx)*2+chx*2+cqx+(11-xfx)*2+gwx+mgx*2+hxx+(11-sgx)+syx+dlx+zlx
            bd = new BigDecimal((11 - vFactorA[0][1] + vFactorA[1][1] + 11 - vFactorA[4][1] + vFactorA[7][1]) * 2
                    + vFactorA[3][1] + vFactorA[6][1] + vFactorA[9][1] + 11 - vFactorA[10][1] + vFactorA[12][1]
                    + vFactorA[13][1] + vFactorA[14][1]);
            vFactorA[22][0] = bd.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue();

            // 在新环境中有成长能力的个性因：chx(+yhx + zlx + (11 - xfx))
            bd = new BigDecimal(vFactorA[1][1] + vFactorA[5][1] + vFactorA[14][1] + 11 - vFactorA[4][1]);
            vFactorA[23][0] = bd.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue();

            // 按标准分得到的指导意见，前16个因子有，后8个因子无
            int[] intValueA = { 8, 7, 5, 4 };
            for (i = 0; i < 16; i++) // “聪慧性”，“实验性”独列出
            {
                if (i == 1 || i == 12) {
                    i += 1;
                }
                vDoctorIdeaA[i] = "Pf16." + String.valueOf(i + 1) + ".5";
                for (j = 0; j < intValueA.length; j++) {
                    if (vFactorA[i][1] >= intValueA[j]) {
                        vDoctorIdeaA[i] = "Pf16." + String.valueOf(i + 1) + "." + String.valueOf(j + 1);
                        break;
                    }
                }
            }

            // 2聪慧性，13实验性
            int[] intCode = { 2, 13 };
            for (i = 0; i < intCode.length; i++) {
                if (vFactorA[intCode[i] - 1][1] >= 8) {
                    vDoctorIdeaA[intCode[i] - 1] = "Pf16." + String.valueOf(intCode[i]) + ".1";
                } else if (vFactorA[intCode[i] - 1][1] >= 4) {
                    vDoctorIdeaA[intCode[i] - 1] = "Pf16." + String.valueOf(intCode[i]) + ".2";
                } else {
                    vDoctorIdeaA[intCode[i] - 1] = "Pf16." + String.valueOf(intCode[i]) + ".3";
                }
            }

            ClsScore.Pf16 pf16 = new ClsScore.Pf16();
            pf16.setLqx_o(vFactorA[0][0]);
            pf16.setLqx_s(vFactorA[0][1]);
            pf16.setLqx_d(vDoctorIdeaA[0]);

            pf16.setChx_o(vFactorA[1][0]);
            pf16.setChx_s(vFactorA[1][1]);
            pf16.setChx_d(vDoctorIdeaA[1]);

            pf16.setWdx_o(vFactorA[2][0]);
            pf16.setWdx_s(vFactorA[2][1]);
            pf16.setWdx_d(vDoctorIdeaA[2]);

            pf16.setCqx_o(vFactorA[3][0]);
            pf16.setCqx_s(vFactorA[3][1]);
            pf16.setCqx_d(vDoctorIdeaA[3]);

            pf16.setXfx_o(vFactorA[4][0]);
            pf16.setXfx_s(vFactorA[4][1]);
            pf16.setXfx_d(vDoctorIdeaA[4]);

            pf16.setYhx_o(vFactorA[5][0]);
            pf16.setYhx_s(vFactorA[5][1]);
            pf16.setYhx_d(vDoctorIdeaA[5]);

            pf16.setGwx_o(vFactorA[6][0]);
            pf16.setGwx_s(vFactorA[6][1]);
            pf16.setGwx_d(vDoctorIdeaA[6]);

            pf16.setMgx_o(vFactorA[7][0]);
            pf16.setMgx_s(vFactorA[7][1]);
            pf16.setMgx_d(vDoctorIdeaA[7]);

            pf16.setHyx_o(vFactorA[8][0]);
            pf16.setHyx_s(vFactorA[8][1]);
            pf16.setHyx_d(vDoctorIdeaA[8]);

            pf16.setHxx_o(vFactorA[9][0]);
            pf16.setHxx_s(vFactorA[9][1]);
            pf16.setHxx_d(vDoctorIdeaA[9]);

            pf16.setSgx_o(vFactorA[10][0]);
            pf16.setSgx_s(vFactorA[10][1]);
            pf16.setSgx_d(vDoctorIdeaA[10]);

            pf16.setYlx_o(vFactorA[11][0]);
            pf16.setYlx_s(vFactorA[11][1]);
            pf16.setYlx_d(vDoctorIdeaA[11]);

            pf16.setSyx_o(vFactorA[12][0]);
            pf16.setSyx_s(vFactorA[12][1]);
            pf16.setSyx_d(vDoctorIdeaA[12]);

            pf16.setDlx_o(vFactorA[13][0]);
            pf16.setDlx_s(vFactorA[13][1]);
            pf16.setDlx_d(vDoctorIdeaA[13]);

            pf16.setZlx_o(vFactorA[14][0]);
            pf16.setZlx_s(vFactorA[14][1]);
            pf16.setZlx_d(vDoctorIdeaA[14]);

            pf16.setJzx_o(vFactorA[15][0]);
            pf16.setJzx_s(vFactorA[15][1]);
            pf16.setJzx_d(vDoctorIdeaA[15]);

            pf16.setSyyjl_o(vFactorA[16][0]);
            pf16.setNxywx_o(vFactorA[17][0]);
            pf16.setGqax_o(vFactorA[18][0]);
            pf16.setQnygd_o(vFactorA[19][0]);
            pf16.setXljk_o(vFactorA[20][0]);
            pf16.setZyycj_o(vFactorA[21][0]);
            pf16.setCzlgx_o(vFactorA[22][0]);
            pf16.setZxhj_o(vFactorA[23][0]);

            result.setObject(pf16);
            return result;

        } catch (ArithmeticException e) {
            result.setMessage(e.toString());
            return result;
        }
    }

    // 四、卡特尔16种个性测验16Pf
    private String[] GetPf16Report(Map map) {
        // 下面因子名称字段改成.toLowerCase()小写，是因为JAVA转json的时候会把大写字母转成小写字母
        // 第一个，错误信息；第二个，量表得分部分；第三个，量表指导意见_d数组部分
        String[] strResult = { "", "", "", "", "" };
        // String[] strResult = {"","",""};
        try {
            int i, j;
            String[] gcName1 = "乐群性,聪慧性,稳定性,恃强性,兴奋性,有恒性,敢为性,敏感性,怀疑性,幻想性,世故性,忧虑性,实验性,独立性,自律性,紧张性".split(",");
            String[] gdName1 = "A,B,C,E,F,G,H,I,L,M,N,O,Q1,Q2,Q3,Q4".split(",");
            String[] geName1 = "Lqx,Chx,Wdx,Cqx,Xfx,Yhx,Gwx,Mgx,Hyx,Hxx,Sgx,Ylx,Syx,Dlx,Zlx,Jzx".toLowerCase()
                    .split(",");

            String[] gcName2 = "适应与焦虑型,内向与外向型,感情用事与安祥机警型,怯懦与果断型,心理健康因素,专业有成就者的个性因素,创造力个性因素,在新环境中有成长能力的个性因素".split(",");
            String[] geName2 = "Syyjl,Nxywx,Gqax,Qnygd,Xljk,Zyycj,Czlgx,Zxhj".toLowerCase().split(",");

            String[] gvName1 = {};
            switch (g_CorE) {
                case 1: // chinese
                    gvName1 = gcName1;
                    break;
                case 2: // english
                    gvName1 = gdName1;
                    break;
            }

            if (g_inblFactor) // 因子得分
            {
                strResult[1] += "<table cellpadding='0' cellspacing='0' width='100%' border='0'>";

                strResult[1] += "<tr><td" + subTitle(1, tWidth) + ">指标</td><td" + subTitle(1, tWidth) + ">原始分</td><td"
                        + subTitle(1, tWidth) + ">标准分</td>" + "<td" + subTitle(1, tWidth) + ">指标</td><td"
                        + subTitle(1, tWidth) + ">原始分</td><td" + subTitle(1, tWidth) + ">标准分</td></tr>";

                // 每二个一行(指标，原始分，标准分)
                for (i = 0; i < gcName1.length; i = i + 2) {
                    strResult[1] += "<tr>";
                    for (j = 0; j < 2; j++) {
                        strResult[1] += "<td" + subTitle(1, -1) + ">" + gvName1[i + j] + "</td>" + "<td"
                                + subValue(1, -1) + ">" + map.get(geName1[i + j] + "_o") + "</td>" + "<td"
                                + subValue(1, -1) + ">" + map.get(geName1[i + j] + "_s") + "</td>";
                    }
                    strResult[1] += "</tr>";
                }
                /*
                 * strResult[1] += "</table>";
                 *
                 * strResult[1] +=
                 * "<table cellpadding='0' cellspacing='0' width='100%' border='0'>";
                 */
                // 每二个一行(指标名，原始分)
                for (i = 0; i < gcName2.length; i = i + 2) {
                    strResult[1] += "<tr><td colspan='2'" + subTitle(0, -1) + ">" + gcName2[i] + "</td><td"
                            + subValue(1, -1) + ">" + map.get(geName2[i] + "_o") + "</td>" + "<td colspan='2'"
                            + subTitle(0, -1) + ">" + gcName2[i + 1] + "</td><td" + subValue(1, -1) + ">"
                            + map.get(geName2[i + 1] + "_o") + "</td></tr>";
                }
                strResult[1] += "</table>";
            }

            String strCode = "";
            for (i = 0; i < gcName1.length; i++) // 前16个因子
            {
                strCode += map.get(geName1[i] + "_d") + "|";
            }
            if (strCode.length() > 0) {
                strCode = strCode.substring(0, strCode.length() - 1);
            }

            strResult[2] = strCode;

            // 以下因子作为预警提醒因子，纯属个人意见
            // 乐群性（5）,聪慧性（3）,稳定性（5）,有恒性（5）,怀疑性（1）,忧虑性（1）,自律性（5）,紧张性（1）
            String[] geNameTemp1 = "Lqx,Wdx,Yhx,Zlx".toLowerCase().split(",");
            String[] gcNameTemp1 = "乐群性,稳定性,有恒性,自律性".split(",");
            for (i = 0; i < geNameTemp1.length; i++) {
                if (Float.valueOf(map.get(geNameTemp1[i] + "_s").toString()) < 4) {
                    strResult[3] = "*";
                    strResult[4] += gcNameTemp1[i].toString() + "极低，";
                }
            }

            if (Float.valueOf(map.get("chx_s").toString()) < 4) {
                strResult[3] = "*";
                strResult[4] += "聪慧性低，";
            }

            String[] geNameTemp2 = "Hyx,Ylx,Jzx".toLowerCase().split(",");
            String[] gcNameTemp2 = "怀疑性,忧虑性,紧张性".split(",");
            for (i = 0; i < geNameTemp2.length; i++) {
                if (Float.valueOf(map.get(geNameTemp2[i] + "_s").toString()) >= 8) {
                    strResult[3] = "*";
                    strResult[4] += gcNameTemp2[i].toString() + "极高，";
                }
            }

            if (strResult[4].length() > 0) {
                strResult[4] = strResult[4].substring(0, strResult[4].length() - 1);
            } else {
                strResult[3] = "0";
                strResult[4] += "正常";
            }

            return strResult;
        } catch (ArithmeticException e) {
            strResult[0] = "失败";
            return strResult;
        }
    }


}
